home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
graphic
/
fgdemo10.zip
/
DISPLAY.C
< prev
next >
Wrap
Text File
|
1991-10-02
|
9KB
|
334 lines
/**********************************************************************\
* *
* display.c -- graphics display functions, bitmaps, scrolling, etc. *
* *
\**********************************************************************/
#include "defs.h"
#include "bitmaps.h"
/**********************************************************************\
* *
* do_bitmaps -- display some bitmaps on the screen *
* *
\**********************************************************************/
do_bitmaps()
{
/* width, height, position and colors of TNT plunger bitmap */
static int tnt_width[] = { 6, 3, 4, 4};
static int tnt_height[] = {28, 25, 27, 17};
static int tnt_color[] = { 0, 7, 8, 15};
static int tnt_xoffset[] = { 0, 24, 16, 16};
static int tnt_yoffset[] = { 0, -2, -1, -2};
static char *tnt_bitmap[4] = {tnt0,tnt7,tnt8,tnt15};
/* width, height, position and colors of "kablooy" explosion */
static int kablooy_width[] = {13, 6};
static int kablooy_height[] = {53, 8};
static int kablooy_color[] = { 4, 15};
static int kablooy_xoffset[] = { 0, 29};
static int kablooy_yoffset[] = { 0,-24};
static char *kablooy_bitmap[2] = {kablooy4,kablooy15};
/* strings for info window */
static char *string[] = {
"Bitmaps",
"Bitmaps can be clipped, flipped, mode-independent",
"and mode-specific.",
};
register int i;
int x,y;
int ymin,ymax;
/* clear lower part of screen */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
/* display the info window */
info_window(120,520,60,string,3);
/* calculate where the TNT bitmap is going to go */
ymin = scale(60);
ymax = ymin + 4 * (ptsize+1);
x = 520;
y = ymax;
/* put the TNT bitmap next to the info window */
fg_mousevis(OFF);
for (i = 0; i < 4; i++)
{
fg_move(x+tnt_xoffset[i],y+tnt_yoffset[i]);
fg_setcolor(tnt_color[i]);
fg_drawmap(tnt_bitmap[i],tnt_width[i],tnt_height[i]);
}
/* save info window to hidden page, to be replaced after the explosion */
x = 440;
y = ymax + 20;
fg_save(400,520,ymin,y);
/* take a rectangular bite out of the info window on the hidden page */
fg_transfer(464,568,144,180,464,y-10,hidden,hidden);
/* pause 1 second */
fg_mousevis(ON);
fg_waitfor(18);
/* move the plunger down */
fg_mousevis(OFF);
fg_transfer(544,567,ymax-30,ymax-25,544,ymax-23,visual,visual);
fg_mousevis(ON);
fg_waitfor(6);
fg_mousevis(OFF);
fg_transfer(544,567,ymax-28,ymax-23,544,ymax-21,visual,visual);
fg_mousevis(ON);
fg_waitfor(6);
fg_mousevis(OFF);
/* display the explosion */
for (i = 0; i < 2; i++)
{
fg_move(x+kablooy_xoffset[i],y+kablooy_yoffset[i]);
fg_setcolor(kablooy_color[i]);
fg_drawmap(kablooy_bitmap[i],kablooy_width[i],kablooy_height[i]);
}
/* blink the "kablooy" text 4 times */
for (i = 0; i < 4; i++)
{
fg_waitfor(3);
fg_move(x+kablooy_xoffset[1],y+kablooy_yoffset[1]);
fg_setcolor(4);
fg_drawmap(kablooy_bitmap[1],kablooy_width[1],kablooy_height[1]);
fg_waitfor(3);
fg_move(x+kablooy_xoffset[1],y+kablooy_yoffset[1]);
fg_setcolor(15);
fg_drawmap(kablooy_bitmap[1],kablooy_width[1],kablooy_height[1]);
}
/* wait a bit, then restore the info window with the corner missing */
fg_waitfor(3);
fg_restore(440,568,y-68,y);
/* draw the torn edges of the info window using the tear bitmap */
fg_setcolor(0);
fg_move(461,ymax);
fg_drawmap(tear,8,29);
/* restore all the stuff on the hidden page */
draw_screen();
/* wait for a keystroke, restore the visual page, and return */
fg_mousevis(ON);
wait_for_keystroke();
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
fg_mousevis(ON);
redraw = TRUE;
return(OK);
}
/**********************************************************************\
* *
* do_scroll -- do a circular scroll of part of the screen *
* *
\**********************************************************************/
do_scroll()
{
register int i;
int y1,y2;
y1 = scale(4);
y2 = ylimit - y1;
fg_mousevis(OFF);
/* save the area under the scroll */
fg_transfer(280,439,y1,y2,0,y2,hidden,hidden);
/* do a nice circular scroll */
for (i = y1; i <= y2; i+=2)
fg_scroll(280,439,y1,y2,-2,0);
/* fix the area under the scroll */
fg_transfer(0,159,y1,y2,280,y2,hidden,hidden);
fg_save(0,159,y1,y2);
fg_mousevis(ON);
return(OK);
}
/**********************************************************************\
* *
* do_transfer -- demo the transfer function *
* *
\**********************************************************************/
do_transfer()
{
register int i;
int x,y;
int ymin,ymax;
static char *string[] = {
"Transfer",
"Use Fastgraph's image transfer routines",
"to copy rectangular areas, either on the",
"same video page or different video pages."
};
/* clear work area of visual page and display the info window */
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
info_window(24,419,60,string,4);
/* save the info window to the hidden page */
ymin = scale(60);
ymax = ymin + 5 * (ptsize+1) + 2;
fg_save(24,419,ymin,ymax);
/* transfer a 6 copies of the info window from hidden page to visual */
x = 56;
y = ymax+ptsize+1;
for (i = 0; i < 6; i++)
{
fg_transfer(24,419,ymin,ymax,x,y,hidden,visual);
x += 32;
y += ptsize;
fg_waitfor(2);
}
/* wait for a keystroke */
fg_mousevis(ON);
wait_for_keystroke();
fg_mousevis(OFF);
/* clear the area where the info window was on the hidden page */
y = 5 * (ptsize+1) + 2;
fg_transfer(24,419,ymax+1,ymax+y+1,24,ymax,hidden,hidden);
/* restore the screen and return */
fg_restore(0,xlimit,menu_bottom,ylimit);
redraw = TRUE;
fg_mousevis(ON);
return(OK);
}
/**********************************************************************\
* *
* view_graphic -- display a graphic image for the selected product *
* *
\**********************************************************************/
view_graphic()
{
int xmin, xmax, ymin, ymax;
static int defaults[] = {0,1,2,3,4,5,20, 7,56,57,58,59,60,61,62,63};
fg_mousevis(OFF);
fg_restore(0,xlimit,menu_bottom,ylimit);
/* define the window extremes */
xmin = 210;
xmax = 430;
ymin = scale(145);
ymax = scale(205);
/* display the status window */
draw_window(xmin,xmax,ymin,ymax,"View Graphic");
fg_setcolor(0);
/* if using the proper video mode, display the image */
if (mode == 16)
{
center_pstring("Loading image...",xmin,xmax,ymin+row_offset(3));
/* display the graphic on the hidden page */
fg_setpage(hidden);
fg_move(0,ylimit);
fg_dispfile("casino.ppr",xlimit+1,1);
fg_setpage(visual);
/* need to adjust the palettes for this graphic */
fg_palette(7,38);
fg_palette(13,39);
fg_fadein(0);
/* restore the hidden page */
draw_screen();
/* wait for a